import React from "react";


import {initNewsList} from "../redux/axios/News"
import {connect} from "react-redux";
class News extends React.Component {


    componentDidMount() {
        initNewsList(1, 10).then(res =>{

            console.log(res)
            this.props.dispatchNewsList(res.data.rows)
        })

    }

    render() {
        const {newsList}=this.props
        console.log(this.props)
        return (
            <div>

                {
                    newsList.map((item,index) =>(
                        <div key={item.articleId}>{item.title}</div>

                    ))
                }

            </div>
        )
    }
};

export default connect(state=>({
    newsList: state.newsList
}),dispatch=>({
    dispatchNewsList(list){

        dispatch({
            type:"newsList",
            list
        })
    }
}))(News)